jQuery(document).ready(function($) {
    var urlFilter = window.location.href;
    //strip remove current select_lk
    $('#main-nav ul.clearfix li.active').removeClass('active');
    $('#page-subheader .wrapper h4').addClass('menuhide');
    //Default
    if (urlFilter.indexOf('/academicadd.xhtml') > -1 || urlFilter.indexOf('/academiclist.xhtml') > -1 || urlFilter.indexOf('/academicdetail.xhtml') > -1 || urlFilter.indexOf('/studentdetail.xhtml') > -1|| urlFilter.indexOf('/studentlist.xhtml') > -1 || urlFilter.indexOf('/studentadd.xhtml') > -1|| urlFilter.indexOf('/examadd.xhtml') > -1|| urlFilter.indexOf('/examinationlist.xhtml') > -1) {
        $('#main-nav ul.clearfix li.manageacademic').addClass('active');
        $('#page-subheader .wrapper h4.manageacademic').removeClass('menuhide');
    }
    if (urlFilter.indexOf('/branchAdd.xhtml') > -1 || urlFilter.indexOf('/branchDetails.xhtml') > -1 || urlFilter.indexOf('/branchList.xhtml') > -1) {
        $('#main-nav ul.clearfix li.managebranch').addClass('active');
        $('#page-subheader .wrapper h4.managebranch').removeClass('menuhide');
    }
    if (urlFilter.indexOf('/classadd.xhtml') > -1 || urlFilter.indexOf('/classlist.xhtml') > -1 || urlFilter.indexOf('/classdetail.xhtml') > -1) {
        $('#main-nav ul.clearfix li.manageclass').addClass('active');
        $('#page-subheader .wrapper h4.manageclass').removeClass('menuhide');
    }
    if (urlFilter.indexOf('/curriculumlist.xhtml') > -1 || urlFilter.indexOf('/curriculumdetail.xhtml') > -1 || urlFilter.indexOf('/curriculumadd.xhtml') > -1) {
        $('#main-nav ul.clearfix li.managecurriculum').addClass('active');
        $('#page-subheader .wrapper h4.managecurriculum').removeClass('menuhide');
    }
    if (urlFilter.indexOf('/roleadd.xhtml') > -1 || urlFilter.indexOf('/roledetail.xhtml') > -1 || urlFilter.indexOf('/rolelist.xhtml') > -1) {
        $('#main-nav ul.clearfix li.managerole').addClass('active');
        $('#page-subheader .wrapper h4.managerole').removeClass('menuhide');
    }
    if (urlFilter.indexOf('/semesteradd.xhtml') > -1 || urlFilter.indexOf('/semesterlist.xhtml') > -1 || urlFilter.indexOf('/semesterdetail.xhtml') > -1) {
        $('#main-nav ul.clearfix li.managesemester').addClass('active');
        $('#page-subheader .wrapper h4.managesemester').removeClass('menuhide');
    }
    if (urlFilter.indexOf('/subjectlist.xhtml') > -1 || urlFilter.indexOf('/subjectdetail.xhtml') > -1 || urlFilter.indexOf('/subjectadd.xhtml') > -1) {
        $('#main-nav ul.clearfix li.managesubject').addClass('active');
        $('#page-subheader .wrapper h4.managesubject').removeClass('menuhide');
    }
    if (urlFilter.indexOf('/stafflist.xhtml') > -1 || urlFilter.indexOf('/staffdetail.xhtml') > -1 || urlFilter.indexOf('/staffadd.xhtml') > -1) {
        $('#main-nav ul.clearfix li.managestaff').addClass('active');
        $('#page-subheader .wrapper h4.managestaff').removeClass('menuhide');
    }
//    else{
//        $('#menusys_css a.itemHome').addClass('select_lk');
//    }
});

function LoadMenu() {
    var urlFilter = window.location.href;
    //strip remove current select_lk
    $('#main-nav ul.clearfix li.active').removeClass('active');
    $('#page-subheader .wrapper h4').addClass('menuhide');
    //Default
    if (urlFilter.indexOf('/academicadd.xhtml') > -1 || urlFilter.indexOf('/academiclist.xhtml') > -1 || urlFilter.indexOf('/academicdetail.xhtml') > -1 || urlFilter.indexOf('/studentdetail.xhtml') > -1|| urlFilter.indexOf('/studentlist.xhtml') > -1 || urlFilter.indexOf('/studentadd.xhtml') > -1|| urlFilter.indexOf('/examadd.xhtml') > -1|| urlFilter.indexOf('/examinationlist.xhtml') > -1) {
        $('#main-nav ul.clearfix li.manageacademic').addClass('active');
        $('#page-subheader .wrapper h4.manageacademic').removeClass('menuhide');
    }
    if (urlFilter.indexOf('/branchAdd.xhtml') > -1 || urlFilter.indexOf('/branchDetails.xhtml') > -1 || urlFilter.indexOf('/branchList.xhtml') > -1) {
        $('#main-nav ul.clearfix li.managebranch').addClass('active');
        $('#page-subheader .wrapper h4.managebranch').removeClass('menuhide');
    }
    if (urlFilter.indexOf('/classadd.xhtml') > -1 || urlFilter.indexOf('/classlist.xhtml') > -1 || urlFilter.indexOf('/classdetail.xhtml') > -1) {
        $('#main-nav ul.clearfix li.manageclass').addClass('active');
        $('#page-subheader .wrapper h4.manageclass').removeClass('menuhide');
    }
    if (urlFilter.indexOf('/curriculumlist.xhtml') > -1 || urlFilter.indexOf('/curriculumdetail.xhtml') > -1 || urlFilter.indexOf('/curriculumadd.xhtml') > -1) {
        $('#main-nav ul.clearfix li.managecurriculum').addClass('active');
        $('#page-subheader .wrapper h4.managecurriculum').removeClass('menuhide');
    }
    if (urlFilter.indexOf('/roleadd.xhtml') > -1 || urlFilter.indexOf('/roledetail.xhtml') > -1 || urlFilter.indexOf('/rolelist.xhtml') > -1) {
        $('#main-nav ul.clearfix li.managerole').addClass('active');
        $('#page-subheader .wrapper h4.managerole').removeClass('menuhide');
    }
    if (urlFilter.indexOf('/semesteradd.xhtml') > -1 || urlFilter.indexOf('/semesterlist.xhtml') > -1 || urlFilter.indexOf('/semesterdetail.xhtml') > -1) {
        $('#main-nav ul.clearfix li.managesemester').addClass('active');
        $('#page-subheader .wrapper h4.managesemester').removeClass('menuhide');
    }
    if (urlFilter.indexOf('/subjectlist.xhtml') > -1 || urlFilter.indexOf('/subjectdetail.xhtml') > -1 || urlFilter.indexOf('/subjectadd.xhtml') > -1) {
        $('#main-nav ul.clearfix li.managesubject').addClass('active');
        $('#page-subheader .wrapper h4.managesubject').removeClass('menuhide');
    }
    if (urlFilter.indexOf('/stafflist.xhtml') > -1 || urlFilter.indexOf('/staffdetail.xhtml') > -1 || urlFilter.indexOf('/staffadd.xhtml') > -1) {
        $('#main-nav ul.clearfix li.managestaff').addClass('active');
        $('#page-subheader .wrapper h4.managestaff').removeClass('menuhide');
    }
//    else{
//        $('#menusys_css a.itemHome').addClass('select_lk');
//    }
}

//academic
jQuery(document).ready(function($) {
    $("#main-nav ul .clearfix li.manageacademic a").click(function() {
        if (window.delayhide)
            clearTimeout(delayhide)
        $('#main-nav ul.clearfix li.manageacademic').removeClass('active');
        $('#main-nav ul.clearfix li.manageacademic').addClass('active');
        $('#page-subheader .wrapper h4').addClass('menuhide');
        $('#page-subheader .wrapper h4.manageacademic').removeClass('menuhide');
    },
    function() {
        delayhide = setTimeout("LoadMenu()", 1000);
    }
    );

});

//branch
jQuery(document).ready(function($) {
    $("#main-nav ul.clearfix li.managebranch a").click(function() {
        if (window.delayhide)
            clearTimeout(delayhide)
        $('#main-nav ul.clearfix li.managebranch').removeClass('active');
        $('#main-nav ul.clearfix li.managebranch').addClass('active');
        $('#page-subheader .wrapper h4').addClass('menuhide');
        $('#page-subheader .wrapper h4.managebranch').removeClass('menuhide');
    },
    function() {
        delayhide = setTimeout("LoadMenu()", 1000);
    }
    );
});

//class
jQuery(document).ready(function($) {
    $("#main-nav ul .clearfix li.manageclass a").click(function() {
        if (window.delayhide)
            clearTimeout(delayhide)
        $('#main-nav ul.clearfix li.manageclass').removeClass('active');
        $('#main-nav ul.clearfix li.manageclass').addClass('active');
        $('#page-subheader .wrapper h4').addClass('menuhide');
        $('#page-subheader .wrapper h4.manageclass').removeClass('menuhide');
    },
    function() {
        delayhide = setTimeout("LoadMenu()", 1000);
    }
    );
});

//curriculum
jQuery(document).ready(function($) {
    $("#main-nav ul.clearfix li.managecurriculum a").click(function() {
        if (window.delayhide)
            clearTimeout(delayhide)
        $('#main-nav ul.clearfix li.managecurriculum').removeClass('active');
        $('#main-nav ul.clearfix li.managecurriculum').addClass('active');
        $('#page-subheader .wrapper h4').addClass('menuhide');
        $('#page-subheader .wrapper h4.managecurriculum').removeClass('menuhide');
    },
    function() {
        delayhide = setTimeout("LoadMenu()", 1000);
    }
    );
});

//role
jQuery(document).ready(function($) {
    $("#main-nav ul.clearfix li.managerole a").click(function() {
        if (window.delayhide)
            clearTimeout(delayhide)
        $('#main-nav ul.clearfix li.managerole').removeClass('active');
        $('#main-nav ul.clearfix li.managerole').addClass('active');
        $('#page-subheader .wrapper h4').addClass('menuhide');
        $('#page-subheader .wrapper h4.managerole').removeClass('menuhide');
    },
    function() {
        delayhide = setTimeout("LoadMenu()", 1000);
    }
    );
});

//semester
jQuery(document).ready(function($) {
    $("#main-nav ul.clearfix li.managesemester a").click(function() {
        if (window.delayhide)
            clearTimeout(delayhide)
        $('#main-nav ul.clearfix li.managesemester').removeClass('active');
        $('#main-nav ul.clearfix li.managesemester').addClass('active');
        $('#page-subheader .wrapper h4').addClass('menuhide');
        $('#page-subheader .wrapper h4.managesemester').removeClass('menuhide');
    },
    function() {
        delayhide = setTimeout("LoadMenu()", 1000);
    }
    );
});

//staff
jQuery(document).ready(function($) {
    $("#main-nav ul.clearfix li.managestaff a").click(function() {
        if (window.delayhide)
            clearTimeout(delayhide)
        $('#main-nav ul.clearfix li.managestaff').removeClass('active');
        $('#main-nav ul.clearfix li.managestaff').addClass('active');
        $('#page-subheader .wrapper h4').addClass('menuhide');
        $('#page-subheader .wrapper h4.managestaff').removeClass('menuhide');
    },
    function() {
        delayhide = setTimeout("LoadMenu()", 1000);
    }
    );
});

//subject
jQuery(document).ready(function($) {
    $("#main-nav ul.clearfix li.managesubject a").click(function() {
        if (window.delayhide)
            clearTimeout(delayhide)
        $('#main-nav ul.clearfix li.managesubject').removeClass('active');
        $('#main-nav ul.clearfix li.managesubject').addClass('active');
        $('#page-subheader .wrapper h4').addClass('menuhide');
        $('#page-subheader .wrapper h4.managesubject').removeClass('menuhide');
    },
    function() {
        delayhide = setTimeout("LoadMenu()", 1000);
    }
    );
});
